

;;; SMALL OBJECT SYSTEM

(define (ask object what . arguments)
  (let ((method (get-method object what)))
    (if (method? method)
        (apply method (cons object arguments))
        (error "No such method" what))))

(define (get-method object which)
  (object which))

(define (method? object)
  (procedure? object))

(define (make-object type)
  (lambda (message)
	(cond
	 ((eq? message 'type)
	  (lambda (self) type))
	 ((eq? message 'is-this-type?)
	  (lambda (self which) (eq? type which)))
	 (else (error "No such method")))))
